home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-11 | 4.8 KB | 211 lines | [TEXT/MPS ] |
- /*
- File: SoundEditorObj.cpp
-
- Contains: EditorPropAccessor class implementation.
-
- Owned by: Andrey Dolgachev
-
- Copyright: © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
- */
-
- // -- Compiler/Preprocessor Switches --
-
- #ifndef _COMPILERDEFS_
- #include "CompDefs.h"
- #endif
-
- // -- OpenDoc Utilities --
-
- #ifndef _EXCEPT_
- // Exceptions define several important macros (eg. CHECKENV)
- // which are used in the SOM method dispatch glue. If Except.h
- // is not included early enough, exceptions may not be thrown
- // correctly when returning from a SOM method with the "ev" parameter set.
- #include <Except.h>
- #endif
-
- // -- SoundEditor Includes --
-
- #ifndef _SOUNDEDITOROBJ_
- #include "SoundEditorObj.h"
- #endif
-
- #ifndef _SOUNDEDITORDEF_
- #include "SoundEditorDef.h"
- #endif
-
- #ifndef _SOUNDEDITOR_
- #include "SoundEditor.h"
- #endif
-
- // -- OpenDoc Includes --
-
- #ifndef __ASREGISTRY__
- #include <ASRegistry.h>
- #endif
-
- // --- Macintosh Includes ---
-
- #ifndef __SOUNDINPUT__
- #include <SoundInput.h>
- #endif
-
- #pragma segment SoundEditorObjectAccessors
-
- //==============================================================================
- // EditorPropAccessor
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // EditorPropAccessor::EditorPropAccessor
- //------------------------------------------------------------------------------
-
- EditorPropAccessor::EditorPropAccessor(DescType property, SoundEditor* part)
- {
- fProperty = property;
- fPart = part;
- }
-
- //------------------------------------------------------------------------------
- // EditorPropAccessor::SetData
- //------------------------------------------------------------------------------
-
- void EditorPropAccessor::SetData(AEDesc* data)
- {
- // Sound Editor only supports setting one property: recording quality
- switch(fProperty)
- {
- // If the specified property is this quality, then get at the specified
- // quality from the AEDesc, and call the SetRecordingQuality method of
- // the SoundEditor class in order to set the quality.
- case pQuality:
- {
- DescType theQual;
-
- theQual = **(DescType**)data->dataHandle;
- switch (theQual)
- {
- case kGoodQuality:
- fPart->SetRecordingQuality( siGoodQuality );
- break;
-
- case kBetterQuality:
- fPart->SetRecordingQuality( siBetterQuality );
- break;
-
- case kBestQuality:
- fPart->SetRecordingQuality( siBestQuality );
- break;
-
- default:
- THROW(paramErr);
- }
- break;
- }
-
- default:
- THROW(errAENoSuchObject);
- break;
- }
- }
-
- //------------------------------------------------------------------------------
- // EditorPropAccessor::GetData
- //------------------------------------------------------------------------------
-
- void EditorPropAccessor::GetData(AEDesc* objectData)
- {
- // Sound Editor supports getting six properties.
- // For each property, the appropriate method of the SoundEditor class is called
- // in order to find out the state of the property, then the value is packaged into
- // an AEDesc used to carry the information.
- switch(fProperty)
- {
- case pState:
- {
- DescType theState;
-
- if ( fPart->SoundPaused() )
- {
- if ( fPart->SoundRecording() )
- theState = kPauseRecordState;
- else if ( fPart->SoundPlaying() )
- theState = kPausePlayState;
- else
- theState = kStopState;
- }
- else
- {
- if ( fPart->SoundRecording() )
- theState = kRecordState;
- else if ( fPart->SoundPlaying() )
- theState = kPlayState;
- else
- theState = kStopState;
- }
-
- THROW_IF_ERROR(AECreateDesc(typeEnumerated, (Ptr) &theState, sizeof(theState),
- objectData));
- break;
- }
-
- case pQuality:
- {
- DescType theQual = (DescType) fPart->GetRecordingQuality();
-
- THROW_IF_ERROR(AECreateDesc(typeEnumerated, (Ptr) &theQual, sizeof(theQual),
- objectData));
- break;
- }
-
- case pCurrentTime:
- {
- long theTime;
-
- theTime = (long) fPart->GetCurrentTime();
-
- THROW_IF_ERROR(AECreateDesc(typeLongInteger, (Ptr) &theTime, sizeof(theTime),
- objectData));
- break;
- }
-
- case pMaxTime:
- {
- long theTime = (long) fPart->GetMaxTime();
-
- THROW_IF_ERROR(AECreateDesc(typeLongInteger, (Ptr) &theTime, sizeof(theTime),
- objectData));
- break;
- }
-
- case pLength:
- {
- long theTime = (long) fPart->GetRecordedTime();
-
- THROW_IF_ERROR(AECreateDesc(typeLongInteger, (Ptr) &theTime, sizeof(theTime),
- objectData));
- break;
- }
-
- case pSndQuality:
- {
- DescType theQual = kUnknownQuality;
- OSType odQual;
-
- if ( fPart->GetSoundQuality(&odQual) )
- theQual = (DescType) odQual;
-
- THROW_IF_ERROR(AECreateDesc(typeEnumerated, (Ptr) &theQual, sizeof(theQual),
- objectData));
- break;
- }
-
- default:
- THROW(errAENoSuchObject);
- break;
- }
- }
-
-
-
-